fft

The fft command will take the Fourier transform of the specified vectors and put the real part in a vector specified by the third argument. The imaginary part will be put in a vector specified by the fourth argument. Input vectors can be used for output. The resulting vectors will contain frequencies ranging from 0 to N/2 followed by - (N/2 - 1) to -1 in units of 1/(N*Δ) where Δ is the sampling rate. If a real vector is transformed h(t) - > H(f ), we should have H(- f )= H*(f ). Therefore, with H = R + iI and H* = R - iI be the transformed vectors, we should have R(- f )= R(f ) and I(- f )= - I(f ), where f is discrete and ranges as mentioned above. In terms of vector indices, these relations become R[i] = R[N - i + 2] and I[i] = - I[N - i + 2] for 1 < i < N/2 in addition to the fact that I[1] = I[(N/2) + 1] = 0. Therefore, because the negative frequency part is the mirror image of the positive one, it is common to plot only the positive frequencies of the Fourier transform of a real vector. This can be done by reducing data to half its value.

Because of the use of a FFT algorithm, the number of data points must be an integer power of 2. If not, the user should pad the vector with zeros up to the next largest power of two. Each transform is normalized by the factor $\sqrt{{(N)}}$ so that fft RE IM T_RE T_IM followed by invfft T_RE T_IMA RE2 IMA2 will not introduce a factor N in vectors RE2 and IMA2 (i.e., RE = RE2 and IM = IM2). At his choice, the user can use the C-calculator functionality in order to implement windowing.

The power spectrum can be obtained from:

      fft RE IMA T_RE T_IMA
      let POW = T_RE^2 + T_IMA^2
where POW[i] will contain the power value associated with frequency f, which goes from 0 to N/2 followed by - (N/2 - 1) to -1 (in units of 1/(N*Δ)) as i goes from 1 to N.

fft real-VECTOR ima-VECTOR real-VECTOR ima-VECTOR

      # real vector X
      let IM=0
      # re-use IM vector for output
      fft X IM Z IM
      # complex vectors X+iY where i = sqrt(-1) transformed in V+iW  
      fft X Y V W

invfft, smooth, cmode, let, read, math, data